
def get_net_io(dev=None):
    file_path = '/proc/net/dev'
    columns = ['dev',
     'rbytes', 'rpackets', 'rerrs', 'rdrop', 'rfifo', 'rframe', 'rcompressed', 'rmulticast',
     'wbytes', 'wpackets', 'werrs', 'wdrop', 'wfifo', 'wcolls', 'wcarrier', 'wcompressed']

    result = {}
    lines = open(file_path, 'r').readlines()
    for line in lines:
        if line == '': continue
        split = line.strip().split()
        if len(split) != len(columns): continue
        data = dict(zip(columns, split))
        if dev is not None and dev != data['dev']:
            continue
        for key in data:
            if key != 'dev':
                data[key] = int(data[key])
        result[data['dev']] = data

    return result
